/**
 * Created by HTWX on 2018/3/16.
 */

var express = require('express');
var router = express.Router();


/* GET users listing. */
router.get('/', function(req, res) {
    var daan=req.query.daan;
    var num =req.query.num;
    res.cookie('num',num, {maxAge:100000*6000, path:'/', httpOnly:false});
    var rs = req.cookies.report;
    if (daan!='' && rs.indexOf("|" + num + ".") == -1)
    {
        rs = rs + "|" + num + "." + daan;
    }
    if (daan!='' && rs.indexOf("|" + num + ".") != -1)
    {
        var list = rs.split('|');
        for (var i = 1; i < list.length; i++)
        {
            var olist = list[i].split('.');
            if ("|" + num + "." == "|" + olist[0] + ".")
            {
                rs = rs.replace("|" + list[i], "|" + olist[0] + "." + daan);
            }
        }
    }
    res.cookie('report',rs, {maxAge:100000*6000, path:'/', httpOnly:false});
    console.log(req.cookies.report);
    res.send('ok');
});

module.exports = router;

